/*
 ============================================================================
 Name		: FEAppContainer.h
 Author	  : Gao QianXuan
 Copyright   : Your copyright notice
 Description : Declares Container class for application.
 ============================================================================
 */

#ifndef __FEAPPDIRCONTAINER_h__
#define __FEAPPDIRCONTAINER_h__

// INCLUDES
#include <e32std.h>
#include <e32base.h>
#include <e32cmn.h>
#include <coecntrl.h>
#include <f32file.h>
#include <aknlists.h>
#include "FEDir.h"
#include "FEFile.h"
#include "FEAppDirView.h"

// CLASS DECLARATION
class CFEAppDirContainer : public CCoeControl, MEikListBoxObserver
{
public:
	// New methods

	/**
	 * NewL.
	 * Two-phased constructor.
	 * Create a CFEAppDirContainer object, which will draw itself to aRect.
	 * @param aRect The rectangle this Container will be drawn to.
	 * @return a pointer to the created instance of CFEAppDirContainer.
	 */
	static CFEAppDirContainer* NewL(const TRect& aRect);

	/**
	 * NewLC.
	 * Two-phased constructor.
	 * Create a CFEAppDirContainer object, which will draw itself
	 * to aRect.
	 * @param aRect Rectangle this Container will be drawn to.
	 * @return A pointer to the created instance of CFEAppDirContainer.
	 */
	static CFEAppDirContainer* NewLC(const TRect& aRect);

	/**
	 * ~CFEAppDirContainer
	 * Virtual Destructor.
	 */
	virtual ~CFEAppDirContainer();

	// Constructors
	/**
	 * ConstructL
	 * 2nd phase constructor.
	 * Perform the second phase construction of a
	 * CFEAppDirContainer object.
	 * @param aRect The rectangle this Container will be drawn to.
	 */
	void ConstructL(const TRect& aRect);

	/**
	 * CFEAppDirContainer.
	 * C++ default constructor.
	 */
	CFEAppDirContainer();

public:
	// Functions from base classes

	/**
	 * From CCoeControl, Draw
	 * Draw this CFEAppDirContainer to the screen.
	 * @param aRect the rectangle of this Container that needs updating
	 */
	void Draw(const TRect& aRect) const;

	/**
	 * From CoeControl, SizeChanged.
	 * Called by framework when the Container size is changed.
	 */
	virtual void SizeChanged();

	/**
	 * From CoeControl, HandlePointerEventL.
	 * Called by framework when a pointer touch event occurs.
	 * Note: although this method is compatible with earlier SDKs, 
	 * it will not be called in SDKs without Touch support.
	 * @param aPointerEvent the information about this event
	 */
	virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent);

	TInt CountComponentControls() const;
	CCoeControl* ComponentControl(TInt aIndex) const;
	TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
	void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);

public:
	// own defined member function
	void SetPath(TFileName &);
	TFileName GetPath();
	CAknDoubleLargeStyleListBox *GetListBoxCtrl();
	void GetCurItem(TInt aIdx, TBool &aIsDir, TFileName &aItem);
	void SetView(CFEAppDirView *aView);

	void GoBackToUpperDirL();
	void OpenL(TInt aIdx);
	void RenameL(TInt aIdx);
	void DeleteL(TInt aIdx);
	void Copy(TInt aIdx);
	void Move(TInt aIdx);
	void PasteL();
	void NewFolderL();
	void RefreshL();
	void GetPropertiesL(TInt aIdx);
	void TransSize(TInt64 aSize, TDes &aBuf);
	TBool TestDuplicationL(TFileName &newName);

private:
	//create list box
	void CreateListBoxL();
	void LoadListBoxIconsL();
	void LoadListBoxItemsL();
	void DeleteAllItemsL();

private:
	// own members

	CAknDoubleLargeStyleListBox *iListbox;
	TInt bufLength;
	TPtrC *iFileExt;
	CDir *iListEntry;
	CFEDir *iDir;
	CFEFile *iFile;
	TFileName iPath;
	TEntry iCurEntry;

	CFEAppDirView *iView;
	TFileName iClipBoardPath;
	TFileName iClipBoardName;
	TBool isCopy;
	TBool isDir;
};

#endif // __FEAPPContainer_h__
// End of File
